/**
 * @file   irenderer-inl.h
 * @Author Alexandre Chassany (alexandre.chassany@gmail.com)
 * @date   February 2011
 * @brief  IRenderer template implementation and specialisation
 *
 * Poum-tchak is a free sound manipulation and synthesis, 
 * real-time and interactive music-clip rendering.
 *
 * Copyright (C) 2011  Chassany Alexandre and Gonzalez Antoine.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * he Free Software Foundation, either version 3 of the License, or
 * at your option) any later version.
 *
 * is program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef _ELIXIR_IRENDERER_INL_H_
#define _ELIXIR_IRENDERER_INL_H_

template<class T>
inline BufferGuard<T> IRenderer::createVertexBuffer(unsigned long size, unsigned long flags, const T* data) const
{
  BufferGuard<T> buffer(createVB(size,sizeof(T), flags));
  if(data)
	buffer.fill(data,size);

  return buffer;
}

template<class T>
inline BufferGuard<T> IRenderer::createIndexBuffer(unsigned long size, unsigned long flags, const T* data) const
{
  BufferGuard<T> buffer(createIB(size,sizeof(T), flags));
  if(data)
	buffer.fill(data,size);

  return buffer;
}

template<class T>
inline void IRenderer::setVertexBuffer(unsigned int stream, const BufferGuard<T>& buffer, unsigned long min_vertex, unsigned long max_vertex)
{
  setVB(stream, buffer.getBuffer(), sizeof(T), min_vertex, max_vertex ? max_vertex : buffer.getCount());
}

template<class T>
inline void IRenderer::setIndexBuffer(const BufferGuard<T>& buffer)
{
  setIB(buffer.getBuffer(), sizeof(T));
}

template<std::size_t N>
IDeclaration* IRenderer::createVertexDeclaration(const DeclarationElement (&elements)[N]) const
{
  return createDeclaration(elements, N);
}

#endif // _ELIXIR_IRENDERER_INL_H_
